let http = require('http');

let users = [
    {id:1, name:'John'},
    {id:2, name:'Jane'},
    {id:3, name:'Jim'}
]

let server = http.createServer(function(req,res){
    res.setHeader('Access-Control-Allow-Origin', '*');
    if (req.url === '/api/users'){ 
        res.end(JSON.stringify(users));
    }else{
        res.end('404')
    }
})

server.listen(3000,()=>{
    console.log('Server is running on port 3000');
});